package com.yiquan.video.controller;

import com.yiquan.video.pojo.Tag;
import com.yiquan.video.service.TagService;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Tyrone
 * @date 2022/3/24 13:38
 */
@RestController
@RequestMapping("/tag")
public class TagController {
    @Autowired
    private TagService tagService;

    /**
     * 分页获取
     *
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/listTagByRefTimes")
    public Result listTagByRefTimes(@RequestParam Integer page, @RequestParam Integer size) {
        List<Tag> tags = tagService.listTagByRefTimesAsPage(page, size);
        return new Result(tags);
    }

    /**
     * 保存标签
     * @param tag
     * @return
     */
    @PostMapping("/saveTag")
    public Result saveTag(@RequestBody Tag tag) {
        tagService.saveTag(tag);
        return new Result(StatusCode.REQUEST_SUCCESS);
    }


}
